import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        long c = scanner.nextLong();
        long[] arr = new long[n];

        //key为arr中的元素，value为该元素出现的次数
        HashMap<Long, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextLong();
            map.put(arr[i], map.getOrDefault(arr[i], 0) + 1);
        }

        long count = 0;
        for (Map.Entry<Long, Integer> entry : map.entrySet()) {
            long a = entry.getKey(); //a
            long b = a - c;
            long num = map.getOrDefault(b, 0);
            count += num * entry.getValue();
        }

        System.out.println(count);

        scanner.close();
    }
}
